package com.seu.multithread.demo01;

/**
 * @author liangfeihu
 * @since 2019/2/18
 */
public class MyThread extends Thread {
    private String threadName;

    public MyThread(String name) {
        super(name);
        this.threadName = name;
    }

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + " 线程运行开始！");
        for (int i = 0; i < 5; i++) {
            System.out.println("子线程" + threadName + "运行：" + i);
            try {
                sleep((long) Math.random() * 10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
        System.out.println(Thread.currentThread().getName() + " 线程运行结束！");
    }

}
